package com.xcx.robot.mirai.factory.facade;

import com.xcx.robot.mirai.factory.BaseFacade;
import com.xcx.robot.mirai.key.KeyWord;
import com.xcx.robot.mirai.util.KeyUtils;
import com.xcx.robot.util.VoiceUtil;
import net.mamoe.mirai.contact.Contact;
import net.mamoe.mirai.message.data.Dice;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Author: 邢晨旭
 * @Date: 2021/7/7 17:41
 * @Description:
 */
@Service
public class VoiceFacade implements BaseFacade {
    public KeyWord keyWord = KeyWord.VOICE;

    @Resource
    VoiceUtil voiceUtil;

    @Override
    public void execute(Contact sender, Contact receiver, String content) {
        String keyByWord = KeyUtils.getKeyByWord(content, 2);
        if (StringUtils.isEmpty(keyByWord)) {
            receiver.sendMessage("指令异常");
            return;
        }
        voiceUtil.process(receiver, keyByWord);
        Dice dice = new Dice(6);
    }

    @Override
    public KeyWord keyWord() {
        return keyWord;
    }
}
